#include "base/condition.h"

namespace net_tools::base{
Condition::Condition(Mutex& mutex)
  :mutex_(mutex)
{
  pthread_cond_init(&cond_,NULL);
};
Condition::~Condition(){
  pthread_cond_destroy(&cond_);
};
void Condition::Wait(){
  pthread_cond_wait(&cond_, mutex_.Get_mutex());
};
void Condition::Signal_one(){
  pthread_cond_signal(&cond_);
};
void Condition::Signal_all(){
  pthread_cond_broadcast(&cond_);
};

} // namespace net_tools::base